In a multi-processor system, it is common practice to use a spin-lock to protect shared data that can be modified by each of a plurality of processors included in the multi-processor system. A spin-lock ensures the integrity of shared data by allowing a single processor in such a multi-processor system to modify the shared data without interference from other processors in the system. In general, the shared data and the spin-lock are moved between the various processors that request access to the shared data. Accordingly, a spin-lock is used much like an access token.
Shared data is typically stored in a main computer memory. Accessing data stored in the main memory is often a slow process. This can reduce the effectiveness of a processor. To regain some of the effectiveness, a processor can be associated with a localized memory known as “cache” memory. A cache memory is a small, high-speed memory that functions to store data or instructions from recently used locations otherwise found in the main memory. In a multi-processor system, each processor has its own cache for storing data.
When a processor requests data from main memory, the cache is concurrently checked for the same data. If the data is found in the cache, then a cache-hit is produced and the main memory access request is abandoned. The requested data is retrieved from the cache in much less time than a full access to the main memory would require. If the data is not found in the cache, then a cache-miss results and the data is retrieved from main memory with the associated time penalty.
In a multi-processor system, each processor has to compete for shared data and an associated spin-lock. When a first processor acquires the spin-lock, it generally triggers a cache-miss, and the spin-lock is copied into the first processor's cache. The first processor can then retrieve shared data from memory, which triggers another cache miss. Once the first processor modifies the shared data and releases the spin-lock, a second processor can then acquire the spin-lock and retrieve the shared data. This process is inefficient because each access to the spin-lock typically results in a cache-miss. Even if a processor can successfully acquire the spin-lock, a second cache-miss results when the processor attempts to access the shared data.